home *** CD-ROM | disk | FTP | other *** search
/ FM Towns: Free Software Collection 6 / FM Towns Free Software Collection 6.iso / ms_dos / cd_lib / src / cdr_tred.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-07-08  |  1.6 KB  |  72 lines

  1. #include <stdlib.h>
  2. #include <stdio.h>
  3. #include <dos.h>
  4. #include "define.h"
  5. /* #include <cdrfrb.h> */
  6.  
  7. #ifdef DEBUG
  8. main(int argc, char *argv[])
  9. {
  10.     struct TIMEADRS time;
  11.     char buf[2340];
  12.     int i;
  13.     
  14.     if (argc > 1) {
  15.         printf("input is %s\n", argv[1]);
  16.         time.min = (u_char) atoi(argv[1]);
  17.         time.sec = 0;
  18.         time.frame = 0;
  19.         printf("Read %d分\n", time.min);
  20.         printf("return is %x\n", cdr_tread(0, &time, buf, 1));
  21.         for (i=0; i<2048; i++) {
  22.             printf("%2x", buf[i]);
  23.             if ((i & 0x1f) == 0x1f) {
  24.                 puts("");
  25.             }
  26.         }
  27.     }
  28. }
  29. #endif
  30.  
  31. /* データの読み取り(時間指定) */
  32. /*
  33.  * device_no:   device number (Towns CD-ROM -> 0)
  34.  * time:     時間
  35.  * buffer: 転送アドレス
  36.  * count:   読み込みセクタ数
  37.  * return: 0 -> 正常終了, 0以外 -> エラー
  38.  */
  39.  
  40. int cdr_tread(int device_no, struct TIMEADRS *time, char *buffer, u_int count)
  41. {
  42.     union REGS reg;
  43.     struct SREGS seg;
  44.  
  45.     if (time == NULL || buffer == NULL) {
  46.         return -1;
  47.     }
  48.  
  49.     segread(&seg);
  50.     reg.h.ah = 0x15;
  51.     reg.h.al = (0xC0 | (u_char) device_no);
  52.     reg.x.cx = 0x0000;
  53.     reg.h.cl = (u_char) time->min;    /* 分 */
  54.     reg.h.dh = (u_char) time->sec;    /* 秒 */
  55.     reg.h.dl = (u_char) time->frame;    /* フレーム */
  56.     reg.x.bx = count;
  57.     reg.x.di = (u_int) buffer;
  58.     
  59.     int86x(0x93, ®, ®, &seg);
  60.  
  61.     if (reg.h.ah == 0) {
  62.         return 0;
  63.     } else if (reg.h.ah == 0x02) {   /* device number error */
  64.         return DEVERR;
  65.     } else if (reg.h.ah == 0x10) {   /* cd-da plaing */
  66.         return DEVPLY;
  67.     } else {                         /* (reg.h.ah == 0x80) hard ware error */
  68.         return reg.x.cx;
  69.     }
  70. }
  71. #define cdr_tread2(device_no, time, buffer, count) cdr_tread(device_no, time, buffer, count)
  72.